/*
 * @Author: silence
 * @Date: 2022-07-26 14:13:07
 * @LastEditors: silence silence9685@163.com
 * @LastEditTime: 2023-06-13 18:06:52
 * @Description: 我的页面-功能列表
 */
import 'package:flutter/material.dart';
import 'package:sil_base_widget_package/sil_base_widget_package.dart';
import '../../../../utils/color/ColorUtils.dart';

class MineFuncsItem extends StatelessWidget {
  final bool? isTop;
  final bool? isBottom;
  final bool? isUpdate;
  final String? title;
  final String? icon;
  final String? subTitle;
  final Widget? subWidget;
  final Function? onTap;

  /// 是否显示右侧箭头，默认显示
  final bool isShowArrow;
  const MineFuncsItem(
      {this.isTop,
      this.isBottom = false,
      this.isUpdate,
      this.title,
      this.icon,
      this.subTitle,
      this.subWidget,
      this.onTap,
      this.isShowArrow = true,
      Key? key})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return itemWidget();
  }

  //功能块 item
  Widget itemWidget() {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        if (onTap != null) onTap!();
      },
      child: Container(
        margin: EdgeInsets.only(left: 12.w, right: 12.w),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(isTop == true ? 12.w : 0),
            topRight: Radius.circular(isTop == true ? 12.w : 0),
            bottomLeft: Radius.circular(isBottom == true ? 12.w : 0),
            bottomRight: Radius.circular(isBottom == true ? 12.w : 0),
          ),
          color: ColorUtils.color_input_bg,
        ),
        height: 56.w,
        child: Column(
          children: [
            Expanded(
              child: Row(
                children: [
                  SizedBox(
                    width: 12.w,
                  ),
                  SilButton(
                    imgPath: icon,
                    width: 24.w,
                    height: 24.w,
                  ),
                  SizedBox(
                    width: 12.w,
                  ),
                  SilText(
                    title,
                    style: TextStyle(
                        fontSize: 16.sp, color: ColorUtils.color_font_main),
                  ),
                  if (isUpdate == true)
                    SizedBox(
                      width: 8.w,
                    ),
                  if (isUpdate == true)
                    SilButton(
                      imgPath: "",
                      backgroundColor: ColorUtils.color_font_main,
                      width: 6.w,
                      height: 6.w,
                      radius: 3.w,
                    ),
                  Expanded(child: SizedBox()),
                  SilText(
                    subTitle,
                    style: TextStyle(
                        fontSize: 14.sp, color: ColorUtils.color_150_151_153),
                  ),
                  if (subWidget != null)
                    Padding(
                      padding: EdgeInsets.only(left: 4.w),
                      child: subWidget,
                    ),
                  if (isShowArrow)
                    SilButton(
                      imgPath: "imgs/personal/list_icon_arrow@3x.png",
                      width: 20.w,
                      height: 20.w,
                    ),
                  SizedBox(
                    width: 6.w,
                  ),
                ],
              ),
            ),
            if (isBottom == false)
              Container(
                color: Color.fromRGBO(0, 0, 0, 0.05),
                height: 0.5.w,
              ),
          ],
        ),
      ),
    );
  }
}
